package com.xyazm.order.factory;


import com.xyazm.order.domain.entity.AfterSaleInfoDO;
import com.xyazm.order.domain.entity.AfterSaleLogDO;
import com.xyazm.order.enums.AfterSaleStateChangeEnum;
import com.xyazm.order.enums.AfterSaleStatusChangeEnum;
import org.springframework.stereotype.Component;

/**
 * 售后单操作日志工厂
 * @author xuyou
 * @date: 2022/7/1 17:07
 */
@Component
public class AfterSaleOperateLogFactory {

    /**
     * 获取售后操作日志
     */
    public AfterSaleLogDO buildAfterSaleLog(AfterSaleInfoDO afterSaleInfoDO, AfterSaleStatusChangeEnum statusChange){
        String operateRemark = statusChange.getOperateRemark();
        Integer preStatus = statusChange.getPreStatus().getCode();
        Integer currentStatus = statusChange.getCurrentStatus().getCode();
        return buildAfterSaleLog(afterSaleInfoDO.getAfterSaleId(), preStatus,currentStatus,operateRemark);
    }

    /**
     * 获取售后操作日志
     */
    public AfterSaleLogDO buildAfterSaleLog(String afterSaleId, AfterSaleStateChangeEnum statusChange){
        String operateRemark = statusChange.getOperateType().getMsg();
        Integer preStatus = statusChange.getFromStatus().getCode();
        Integer currentStatus = statusChange.getToStatus().getCode();
        return buildAfterSaleLog(afterSaleId, preStatus,currentStatus,operateRemark);
    }



    /**
     * 创建售后单操作日志
     * @param afterSaleId 售后单id
     * @param preStatus  前置状态
     * @param currentStatus 当前状态
     * @param operateRemark 备注
     */
    public AfterSaleLogDO buildAfterSaleLog(String afterSaleId, int preStatus, int currentStatus, String operateRemark) {
        AfterSaleLogDO log = new AfterSaleLogDO();
        log.setAfterSaleId(afterSaleId);
        log.setPreStatus(preStatus);
        log.setCurrentStatus(currentStatus);
        log.setRemark(operateRemark);
        return log;
    }


}
